<!--这里是评分星星的代码-->
const stars = document.querySelectorAll('#pingStar li');
const hiddenInput = document.getElementById('startP');
let currentRating = 0;  // 用于记录当前评分

stars.forEach(star => {
    star.addEventListener('click', function() {
        const rating = parseInt(star.getAttribute('rel'));

        // 如果当前点击的星星的评分与当前评分相同，则重置为0，否则设置为点击的评分
        if (rating === currentRating) {
            currentRating = 0;
            hiddenInput.value = 0;
        } else {
            currentRating = rating;
            hiddenInput.value = rating;
        }

        highlightStars(currentRating);
    });
});

function highlightStars(rating) {
    stars.forEach((star, index) => {
        if (index < rating) {
            star.classList.remove('inactive');
            star.classList.add('active');
        } else {
            star.classList.remove('active');
            star.classList.add('inactive');
        }
    });
}